# MIT License
#
# Copyright (C) The Adversarial Robustness Toolbox (ART) Authors 2018
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
from os.path import dirname, join
import unittest

import numpy as np
import tensorflow as tf

from tensorflow.keras.models import load_model  # noqa: E402

from art.attacks.extraction.functionally_equivalent_extraction import FunctionallyEquivalentExtraction  # noqa: E402
from art.estimators.classification.keras import KerasClassifier  # noqa: E402
from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin  # noqa: E402
from art.estimators.classification.classifier import ClassifierMixin  # noqa: E402

from tests.utils import TestBase, master_seed  # noqa: E402
from tests.attacks.utils import backend_test_classifier_type_check_fail  # noqa: E402

logger = logging.getLogger(__name__)


class TestFunctionallyEquivalentExtraction(TestBase):
    @classmethod
    def setUpClass(cls):
        master_seed(seed=1234, set_tensorflow=True)
        super().setUpClass()

        cls.n_train = 100
        cls.n_test = 11
        cls.x_train_mnist = cls.x_train_mnist[0 : cls.n_train]
        cls.y_train_mnist = cls.y_train_mnist[0 : cls.n_train]
        cls.x_test_mnist = cls.x_test_mnist[0 : cls.n_test]
        cls.y_test_mnist = cls.y_test_mnist[0 : cls.n_test]

        model = load_model(
            join(
                *[
                    dirname(dirname(dirname(__file__))),
                    "utils",
                    "data",
                    "test_models",
                    "model_test_functionally_equivalent_extraction.keras",
                ]
            )
        )

        np.random.seed(0)
        num_neurons = 4
        img_rows = 28
        img_cols = 28
        num_channels = 1

        x_train = cls.x_train_mnist.reshape(cls.n_train, img_rows, img_cols, num_channels)
        x_test = cls.x_test_mnist.reshape(cls.n_test, img_rows, img_cols, num_channels)

        x_train = x_train.reshape((x_train.shape[0], num_channels * img_rows * img_cols)).astype("float64")
        x_test = x_test.reshape((x_test.shape[0], num_channels * img_rows * img_cols)).astype("float64")

        mean = np.mean(x_train)
        std = np.std(x_train)

        x_train = (x_train - mean) / std

        classifier = KerasClassifier(model=model, use_logits=True, clip_values=(0, 1))

        cls.fee = FunctionallyEquivalentExtraction(classifier=classifier, num_neurons=num_neurons)
        fee_extracted = cls.fee.extract(
            x_train[0:10],
            delta_0=3.5,
            fraction_true=0.03,
            rel_diff_slope=0.00001,
            rel_diff_value=0.000001,
            delta_init_value=0.1,
            delta_value_max=1,
            d2_min=0.00000000000000000001,
            d_step=0.5,
            delta_sign=0.02,
            unit_vector_scale=10000,
            ftol=1e-8,
        )
        fee_extracted.predict(x=x_test)

    def setUp(self):
        master_seed(seed=1234, set_tensorflow=True)
        super().setUp()

    def test_critical_points(self):
        critical_points_expected_3 = np.array(
            [
                [
                    8.19612722e00,
                    2.40234234e00,
                    8.11413371e00,
                    7.94101531e00,
                    -1.64722226e01,
                    -1.53566335e00,
                    -9.27154880e00,
                    -8.26856781e-01,
                    -1.22067410e01,
                    1.81122897e01,
                    -1.14411810e01,
                    -1.06700356e01,
                    1.76700751e00,
                    -1.44054912e01,
                    -5.28370124e00,
                    -1.08603133e01,
                    2.05269904e01,
                    1.03932195e01,
                    -4.62041357e-01,
                    -6.13056036e00,
                    1.01374552e01,
                    6.11873056e00,
                    7.58182205e00,
                    -1.09542778e00,
                    -2.04999226e01,
                    -2.97122895e00,
                    -7.13609668e00,
                    8.51287487e00,
                    1.51798091e01,
                    -7.40462919e00,
                    6.47220303e00,
                    2.37904961e01,
                    -9.89343243e00,
                    2.07037990e01,
                    -1.18469995e01,
                    4.66014249e-01,
                    1.07996639e00,
                    1.35746905e00,
                    -1.16853480e01,
                    -8.27577097e00,
                    -1.00543017e01,
                    2.98982708e00,
                    2.74501483e00,
                    3.19727707e01,
                    1.79812979e01,
                    -7.31448680e00,
                    3.12882099e00,
                    1.42259270e01,
                    -1.20116164e00,
                    -1.15201765e00,
                    -1.99859457e-01,
                    1.20841289e01,
                    -1.19523648e01,
                    -5.57303640e00,
                    6.31669418e00,
                    4.62891424e00,
                    3.29784354e00,
                    -4.68515009e00,
                    1.24825670e01,
                    2.84173957e01,
                    4.80899022e00,
                    -2.96498671e00,
                    9.37975526e00,
                    -8.99773017e00,
                    -9.93387795e00,
                    4.07207263e-02,
                    -3.64651703e01,
                    -1.51009010e01,
                    -5.60036686e00,
                    -1.82016261e01,
                    -1.31984843e01,
                    -5.76157615e00,
                    -2.10197772e01,
                    -6.71164094e00,
                    -6.81701158e00,
                    -3.42162237e-01,
                    1.46960376e01,
                    1.74777042e00,
                    -2.74825771e-02,
                    1.39753817e00,
                    1.90176640e00,
                    -1.28122402e01,
                    -1.08234764e00,
                    2.62797920e00,
                    -1.69996090e01,
                    1.35712162e01,
                    1.57636305e01,
                    -8.69548684e00,
                    -4.32574959e00,
                    -1.07899713e01,
                    9.02958258e00,
                    -1.30905861e01,
                    -2.79234084e00,
                    -1.06078777e01,
                    1.04360239e00,
                    -2.34927485e01,
                    1.79008959e01,
                    -1.12240728e01,
                    9.34730092e-01,
                    -2.46437426e00,
                    -8.39572195e00,
                    -1.33215226e01,
                    1.13590100e01,
                    -6.12007952e00,
                    2.48423222e00,
                    -8.86641364e00,
                    -9.14235386e00,
                    5.62188764e00,
                    1.44716474e01,
                    -8.84031409e-01,
                    -1.73103114e01,
                    2.78530924e01,
                    -1.24137695e01,
                    -1.88817981e01,
                    3.47237984e01,
                    -4.64685133e00,
                    -1.87675860e01,
                    -9.37277228e00,
                    5.57127034e00,
                    3.48899714e00,
                    -1.11111079e01,
                    2.34842326e01,
                    -6.73646725e00,
                    -1.46518463e01,
                    1.22625993e01,
                    1.77758445e01,
                    -1.14609342e01,
                    -1.70511379e01,
                    1.45701324e01,
                    -2.72054210e01,
                    -1.73137394e01,
                    1.35874928e01,
                    -1.42088949e00,
                    -3.52797358e00,
                    4.12269993e00,
                    -1.38408231e00,
                    -1.69391961e01,
                    1.70025216e01,
                    1.82668785e01,
                    1.67632189e00,
                    -8.82521255e-01,
                    3.19946305e01,
                    -3.56166124e00,
                    -2.86596310e00,
                    7.29901540e00,
                    2.07886509e01,
                    2.05693665e01,
                    -2.37043227e00,
                    2.84265087e00,
                    -1.90482199e01,
                    -4.27595926e00,
                    -9.61991210e00,
                    -1.43242041e01,
                    2.18535035e01,
                    -1.07842662e01,
                    -7.83341055e00,
                    6.06095096e00,
                    1.64242367e01,
                    5.34147892e00,
                    3.67784504e01,
                    -1.50510242e00,
                    5.41892020e00,
                    4.66653180e00,
                    1.94425034e01,
                    5.61585211e00,
                    -7.23262715e-01,
                    -1.37792852e01,
                    1.75211292e00,
                    2.00883982e01,
                    -5.21800277e00,
                    8.05488397e00,
                    3.63859853e00,
                    1.25033856e01,
                    -1.15049866e01,
                    3.06157069e01,
                    -1.65708445e01,
                    -5.73370956e00,
                    1.19627926e01,
                    3.54659899e00,
                    1.12117576e01,
                    -7.04507856e00,
                    -2.38386909e00,
                    -4.78641880e-01,
                    1.89416836e01,
                    9.93725990e00,
                    9.14290392e00,
                    -9.97803476e00,
                    1.31197830e01,
                    2.30292623e00,
                    2.02788444e01,
                    2.58713914e01,
                    -3.87039343e00,
                    -5.51921801e00,
                    -1.28217338e01,
                    -1.41322434e00,
                    -5.32404097e00,
                    5.62053688e00,
                    -1.12631294e00,
                    -2.71376468e00,
                    1.56949149e01,
                    -1.30186608e01,
                    5.60208090e00,
                    -4.37540124e00,
                    1.04250444e01,
                    1.93235798e01,
                    -5.70493534e00,
                    5.92402024e00,
                    1.67340342e00,
                    -1.05021310e01,
                    3.14942476e00,
                    4.80963602e00,
                    5.88573386e00,
                    -1.88953894e00,
                    8.03981407e-01,
                    -1.64226278e01,
                    -5.24004429e00,
                    7.48141912e00,
                    1.24162213e01,
                    -3.43658088e00,
                    1.37005315e00,
                    2.11988029e00,
                    2.37144019e00,
                    6.82998357e00,
                    -2.40394903e01,
                    -2.20604591e00,
                    3.28718164e00,
                    -1.33352563e01,
                    2.28097408e01,
                    1.58168342e00,
                    2.08481986e01,
                    -1.20860879e01,
                    -1.27303555e01,
                    2.48169715e00,
                    -2.22249358e01,
                    1.74312456e00,
                    2.09242376e00,
                    1.51930744e01,
                    7.38517500e00,
                    -5.20438659e00,
                    -1.41253667e01,
                    2.24569498e01,
                    -1.10807705e01,
                    -1.42341916e01,
                    -1.49295780e01,
                    1.47604272e01,
                    -8.67457034e00,
                    -9.01311221e00,
                    2.93668359e00,
                    -3.60449117e00,
                    -1.06121062e01,
                    1.06903795e01,
                    1.37924495e01,
                    1.34312332e01,
                    1.00243529e01,
                    6.12187303e00,
                    -2.32571981e01,
                    2.17881013e01,
                    2.68965734e00,
                    6.61945425e00,
                    1.56482189e01,
                    1.81432065e01,
                    5.13624621e00,
                    5.27803087e00,
                    -8.13448929e00,
                    -1.48998816e00,
                    -1.13315568e01,
                    -9.18616820e00,
                    -1.19634905e01,
                    -2.41522834e00,
                    1.42468424e01,
                    4.31669577e01,
                    -2.16752904e-01,
                    -1.62305494e01,
                    1.74513123e01,
                    -4.70917317e00,
                    -9.30078451e00,
                    3.32404618e00,
                    -1.68487892e01,
                    9.69744597e-01,
                    8.72545019e-01,
                    1.21631241e00,
                    6.16445096e00,
                    2.18238969e-01,
                    1.75673382e00,
                    4.12098099e00,
                    6.21147975e00,
                    -1.49571743e01,
                    -1.80755863e01,
                    -1.41513189e-01,
                    -1.80218977e01,
                    5.52476291e-01,
                    1.21801405e01,
                    1.04922184e01,
                    -1.51970122e01,
                    -1.17385738e01,
                    5.56479183e00,
                    -5.31470187e00,
                    -3.68787361e00,
                    7.65121214e00,
                    -1.29457832e01,
                    -6.71810270e00,
                    -9.13282757e00,
                    -1.41871722e01,
                    -1.22398551e01,
                    9.80352357e00,
                    2.38197732e-01,
                    -1.31917681e01,
                    -4.46365591e00,
                    -2.14093247e01,
                    -1.00499887e01,
                    2.88582708e01,
                    -1.39402730e-01,
                    8.74128301e00,
                    -1.61393960e00,
                    4.31098567e00,
                    9.03991729e00,
                    -1.49404750e01,
                    -7.04134002e-01,
                    2.12330137e01,
                    -1.08364657e01,
                    -8.35935279e00,
                    -4.96291981e00,
                    3.90292671e00,
                    6.18881347e00,
                    1.59366153e01,
                    6.42459394e00,
                    -9.94596595e-01,
                    1.92394976e01,
                    8.79186148e00,
                    -1.92294286e01,
                    3.48210932e01,
                    2.26825288e01,
                    -1.49550394e00,
                    3.91310905e00,
                    1.52028613e01,
                    -1.71620549e00,
                    8.09458848e00,
                    1.53487238e01,
                    -1.43712798e01,
                    -6.46428403e00,
                    1.34958276e01,
                    5.76176068e00,
                    1.17716905e01,
                    -3.00206296e00,
                    -4.33882474e00,
                    -2.72366204e01,
                    -1.58211535e01,
                    7.91498739e-01,
                    1.16995781e01,
                    7.51382034e00,
                    -2.49378284e00,
                    -5.10325812e00,
                    4.29370030e00,
                    3.65409052e-01,
                    1.82912434e01,
                    1.45390237e00,
                    -2.18210891e01,
                    -1.76413567e01,
                    2.00043181e01,
                    -1.51754428e01,
                    1.10094693e01,
                    -3.61585467e00,
                    -1.35773391e00,
                    -1.46912508e00,
                    1.64575122e01,
                    -2.43998884e00,
                    -6.40040902e-01,
                    -2.10412668e01,
                    2.51996492e00,
                    6.03432217e00,
                    3.50587165e00,
                    1.78607329e01,
                    1.58574428e00,
                    3.78294226e00,
                    2.22833752e01,
                    -2.04116810e01,
                    -5.50454209e00,
                    1.76644180e01,
                    1.24189579e01,
                    1.00296998e01,
                    9.53211061e00,
                    4.79852296e00,
                    1.97502917e01,
                    4.07244718e00,
                    3.27379193e00,
                    4.87209390e-01,
                    1.61570471e00,
                    -1.70768827e01,
                    1.20424393e01,
                    -1.59505302e00,
                    2.51400192e01,
                    -1.24299625e00,
                    5.32362252e00,
                    1.70952529e00,
                    -8.72891735e00,
                    1.26197621e01,
                    2.65521027e01,
                    9.41796963e-01,
                    -2.58607101e00,
                    -3.93582967e00,
                    -2.61215204e01,
                    -3.51411750e00,
                    4.15195191e00,
                    1.45821371e01,
                    1.11799205e01,
                    -5.26196934e00,
                    -2.91907699e00,
                    1.52173819e01,
                    -2.52461456e00,
                    -7.68657364e00,
                    1.73347896e01,
                    1.47945347e01,
                    -5.56637736e-02,
                    -8.24192559e00,
                    -2.54021270e01,
                    8.63801487e00,
                    -1.17187889e01,
                    -2.63299080e01,
                    2.28949564e01,
                    1.04589301e01,
                    -1.44326485e01,
                    -1.57967801e01,
                    9.65232617e00,
                    -1.17177376e01,
                    1.73514647e01,
                    8.40832944e00,
                    8.18028828e00,
                    2.71857482e00,
                    2.01284470e00,
                    1.21456295e01,
                    -6.59116695e00,
                    -2.57645431e-01,
                    1.10106982e01,
                    7.87008727e00,
                    -1.70882589e01,
                    -6.43436177e00,
                    4.23122429e00,
                    -5.49772713e00,
                    2.47359302e01,
                    -5.22431779e00,
                    -2.58311904e00,
                    9.21812077e00,
                    4.37206593e00,
                    -1.76506831e00,
                    -9.32722796e00,
                    3.95150529e00,
                    1.44720287e01,
                    5.49709252e00,
                    -1.12782295e01,
                    2.33140283e01,
                    -2.05650691e01,
                    -2.05259198e01,
                    1.34184608e01,
                    3.32507571e00,
                    -7.07235165e00,
                    -1.27957175e01,
                    3.08324765e01,
                    -6.22200706e-01,
                    7.40423557e00,
                    4.23681046e00,
                    5.34686952e00,
                    6.30559012e00,
                    9.43923820e00,
                    -4.87940141e00,
                    -4.43628180e00,
                    -2.10692560e01,
                    -1.14847097e01,
                    2.86346425e00,
                    1.18059314e01,
                    8.33091462e00,
                    -6.61142898e00,
                    -1.75762559e01,
                    -3.77347669e01,
                    1.48240621e01,
                    -6.20823976e00,
                    -5.05419098e00,
                    3.09371542e00,
                    -1.98396392e01,
                    -3.58902570e00,
                    2.77871890e01,
                    7.58771492e00,
                    5.87474261e00,
                    -2.22523526e01,
                    2.98358307e01,
                    -1.83270762e01,
                    2.32713657e01,
                    -2.70130824e01,
                    1.95077277e01,
                    2.17774913e01,
                    -1.08985515e01,
                    4.66953607e00,
                    7.03409537e00,
                    -9.87561197e00,
                    -1.82466726e01,
                    -1.50762347e01,
                    7.22281947e00,
                    -1.80653326e00,
                    -8.12513543e00,
                    1.20210554e01,
                    6.77461329e00,
                    -9.80642554e00,
                    -1.62352163e01,
                    8.15373873e00,
                    -7.48476791e00,
                    9.90555818e-01,
                    2.06787602e01,
                    5.14242083e00,
                    -1.31974278e01,
                    9.87728914e-01,
                    -1.15471872e01,
                    2.25898930e01,
                    -6.19922113e00,
                    1.46331261e00,
                    2.18185912e00,
                    1.48780369e00,
                    -2.62397327e01,
                    -1.90096352e01,
                    -5.05301504e00,
                    4.59255498e00,
                    -1.15601828e-01,
                    -1.31319478e01,
                    -1.90996924e01,
                    -7.09714823e00,
                    -7.20745175e00,
                    7.15890088e00,
                    -5.28987765e00,
                    9.06564586e00,
                    -6.60789650e00,
                    -5.82176666e00,
                    -3.83015619e00,
                    -1.27916278e01,
                    8.83266650e00,
                    -9.74834870e00,
                    -6.97068326e00,
                    -2.26587631e00,
                    -1.80835894e01,
                    -4.64414309e00,
                    -9.77585227e00,
                    -5.43805173e00,
                    -9.18150170e-01,
                    -1.05752008e01,
                    -4.17680333e00,
                    1.74083978e01,
                    1.17030809e00,
                    1.50618575e01,
                    4.22944094e00,
                    1.15195394e01,
                    -1.30045508e01,
                    2.59629378e00,
                    1.17422099e00,
                    -8.09874305e00,
                    -1.10014171e01,
                    -1.91571992e01,
                    1.99113004e01,
                    -1.37931224e01,
                    1.94547432e01,
                    -8.66939793e00,
                    -1.16123780e01,
                    7.04818155e00,
                    -9.27465310e00,
                    9.67823683e00,
                    -4.53332999e00,
                    6.67470253e00,
                    -1.48397859e01,
                    1.04836426e01,
                    6.77799495e00,
                    -1.20488538e01,
                    3.62629729e01,
                    7.29343316e00,
                    3.14192375e01,
                    2.20370858e01,
                    -4.37661313e00,
                    -5.52343014e00,
                    -4.67367560e00,
                    -2.40922777e01,
                    -9.74880092e00,
                    2.52258270e00,
                    1.94627467e01,
                    -1.05536659e01,
                    1.30296483e01,
                    -1.88459155e01,
                    -8.56777011e00,
                    -7.31214180e00,
                    5.79968785e00,
                    5.61356613e00,
                    1.25087612e01,
                    1.01795654e01,
                    3.72507771e00,
                    4.87258297e00,
                    1.83788586e01,
                    -6.34770654e00,
                    1.08880419e01,
                    -2.46065339e01,
                    4.46375473e00,
                    -6.16595499e00,
                    4.13913861e-01,
                    1.35579300e01,
                    2.00387019e00,
                    1.10086399e01,
                    1.96985299e01,
                    3.69740060e00,
                    1.62115096e01,
                    -5.34879676e00,
                    1.27373942e-01,
                    -8.45469161e00,
                    1.34769017e01,
                    5.47448795e00,
                    -8.50192689e00,
                    2.20121397e00,
                    1.36688054e01,
                    -2.27197566e00,
                    -1.41017912e01,
                    2.38425448e00,
                    -2.58169408e01,
                    1.02367373e01,
                    -5.27781285e00,
                    -6.10589458e00,
                    1.21403997e01,
                    -1.71263873e01,
                    2.47541194e01,
                    -5.80071128e00,
                    -7.43925525e00,
                    1.35493130e01,
                    9.25614123e00,
                    3.26853415e01,
                    -4.07479621e00,
                    -1.44062214e00,
                    -1.82810462e01,
                    -4.53529850e00,
                    -9.73155065e00,
                    -6.73995767e00,
                    -2.36418709e01,
                    2.28632910e01,
                    -1.94764090e01,
                    -3.82479744e01,
                    -1.56253809e01,
                    -9.06217440e00,
                    -1.52518923e01,
                    1.56334792e01,
                    -4.99130824e-01,
                    2.52001441e-01,
                    9.60013856e00,
                    4.89194874e00,
                    1.22020253e01,
                    -1.61818033e01,
                    -7.68950854e00,
                    1.00110391e01,
                    -3.42566020e01,
                    -1.91481933e01,
                    8.30927939e00,
                    -6.19036185e00,
                    1.03049760e01,
                    1.12308240e01,
                    -1.56390063e01,
                    5.71031778e00,
                    1.66573804e01,
                    1.92121748e00,
                    -1.45017651e01,
                    1.14898984e01,
                    7.62455009e00,
                    6.38561749e00,
                    8.39301954e00,
                    -3.99367749e01,
                    1.19793718e01,
                    2.39386641e01,
                    5.23973938e00,
                    2.57597210e00,
                    1.04722772e01,
                    2.55753520e00,
                    9.16765072e00,
                    -5.25872142e-01,
                    -1.22253699e01,
                    -1.54913122e01,
                    -1.43757021e01,
                    -1.82991373e01,
                    -1.40079017e01,
                    2.28157560e01,
                    1.11877410e01,
                    -7.00695302e00,
                    -4.86925966e00,
                    9.26695345e-01,
                    -7.71711810e00,
                    1.66601630e00,
                    1.13551934e01,
                    -1.13853691e00,
                    1.69739309e00,
                    1.40731749e01,
                    -5.28120303e00,
                    3.80529027e00,
                    -1.79192533e00,
                    -5.42008793e-02,
                    -3.43049041e00,
                    -8.63542683e00,
                    5.65238195e-01,
                    7.10846800e00,
                    3.06400276e00,
                    6.38023432e00,
                    -1.07473490e01,
                    -1.60371792e01,
                    6.70672912e00,
                    7.83272754e00,
                    -5.38102716e-01,
                    1.73927036e01,
                    1.33370510e01,
                    3.63885043e01,
                    -5.76212734e-01,
                    -1.25353350e01,
                    -1.00175475e01,
                    -6.36196488e00,
                    6.63187858e00,
                    -2.98114553e01,
                    1.84636777e01,
                    -3.92379332e00,
                    -3.61897766e00,
                    -1.32296503e01,
                    -1.64187660e00,
                    -6.24572572e-01,
                    -2.10904641e00,
                    5.59478698e00,
                    -8.50508924e00,
                    -1.24690133e01,
                    6.88517728e00,
                    1.51468377e00,
                    2.27395173e00,
                    1.26815900e01,
                    -1.46788212e01,
                    -1.24676799e01,
                    1.81998272e01,
                    -1.91874296e01,
                    -1.70731847e01,
                    1.05253956e01,
                    2.39688766e00,
                    9.11780573e-01,
                    -2.28811871e00,
                    2.91891541e00,
                    -3.48766605e00,
                    1.88452808e01,
                    -6.65449848e00,
                    -2.28083797e00,
                    2.32142806e01,
                    -8.06597156e-01,
                    2.89636947e01,
                    3.39092662e-01,
                    1.83097577e01,
                    -2.30918360e01,
                    2.62803703e00,
                    -2.13599326e01,
                    1.21094485e01,
                    -1.81825777e01,
                    4.13089110e00,
                    -3.03336768e00,
                    -1.72826406e01,
                    -2.13926105e01,
                    -5.19637822e00,
                    2.34615466e01,
                    -3.13691720e00,
                    1.30414193e01,
                    -1.47686039e00,
                    1.18644502e01,
                    -2.62071100e01,
                    -5.88922765e00,
                    1.30706121e01,
                    -1.47876918e00,
                    -1.14143684e00,
                    -5.08578837e00,
                    1.43991268e01,
                    3.91097026e00,
                    6.13021353e-01,
                    1.05226655e01,
                    7.71940375e00,
                    2.36821019e00,
                    2.08866405e01,
                    -1.73222994e00,
                    3.94331841e00,
                    -9.03675391e00,
                    2.33322655e-01,
                    2.13560411e01,
                    -8.99335607e00,
                    -1.69215381e01,
                    1.33764695e01,
                    -5.17098855e-01,
                    1.81614197e00,
                    3.47020068e-03,
                    -2.74357718e-01,
                ]
            ]
        )
        np.testing.assert_array_almost_equal(self.fee.critical_points[3], critical_points_expected_3, decimal=2)

    # def test_layer_0_biases(self):
    #     layer_0_biases_expected = np.array(
    #         [
    #             [3.52880724],
    #             [1.04879517],
    #             [1.50037751],
    #             [1.28102357],
    #             [-0.12998148],
    #             [1.31377369],
    #             [-0.37855184],
    #             [0.31751928],
    #             [-0.83950368],
    #             [1.00915159],
    #             [-0.22809063],
    #             [-0.09700302],
    #             [0.20176007],
    #             [-0.48283775],
    #             [0.15261177],
    #             [0.40842637],
    #         ]
    #     )
    #     np.testing.assert_array_almost_equal(self.fee.b_0, layer_0_biases_expected, decimal=2)

    # def test_layer_1_biases(self):
    #     layer_1_biases_expected = np.array(
    #         [
    #             [0.35597115],
    #             [0.16081501],
    #             [-0.4898516],
    #             [-1.52676063],
    #             [0.23123853],
    #             [-1.26165748],
    #             [-0.74085385],
    #             [-1.01602675],
    #             [-0.50653434],
    #             [1.91474429],
    #         ]
    #     )
    #     np.testing.assert_array_almost_equal(self.fee.b_1, layer_1_biases_expected, decimal=2)

    def test_classifier_type_check_fail(self):
        backend_test_classifier_type_check_fail(
            FunctionallyEquivalentExtraction, [BaseEstimator, NeuralNetworkMixin, ClassifierMixin]
        )


if __name__ == "__main__":
    unittest.main()
